﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Game1942.Library.Weapons;
using Microsoft.Xna.Framework.Input;

namespace Game1942.Library.Controller
{
    public class Algo42ShootController
    {
        private Algo42 algo42;      //copy of the reference player

        public Algo42ShootController(Algo42 player)
        {
            algo42 = player;
        }

        public Ammo KeyPressed(KeyboardState keyboardState, KeyboardState previousKeyboardState, ref string ammoName)
        {
            Keys[] pressedKeys = keyboardState.GetPressedKeys();
            Ammo currentAmmo = null;
           
            foreach (Keys key in pressedKeys)
            {
                if (previousKeyboardState.IsKeyUp(key))
                {
                    switch (key)
                    {
                        case Keys.A:
                            {
                                currentAmmo = algo42.ShootLaser();
                                ammoName = "Laser";
                                break;
                            } //Laser firing
                        case Keys.S:
                            {
                                currentAmmo = algo42.ShootRocket();
                                ammoName = "Rocket";
                                break;
                            } //Rocket firing
                        case Keys.D:
                            {
                                currentAmmo = algo42.ShootTorpedo();
                                ammoName = "Torpedo";
                                break;
                            } //Torpedo firing
                    }
                }
            }
            return currentAmmo;
        }
    }
}
